# coding=utf-8

import requests
import re

url_login = "https://gitee.com/login"
url_post = "https://gitee.com/login"
url_get = "https://gitee.com/jfedu_python2017"

s = requests.session()
r = s.get(url_login)
pattern = re.compile(r'<input name="authenticity_token" type="hidden" value="(.*)" /></div>')
authenticity_token = pattern.findall(r.text)
"""
utf8:✓
authenticity_token:ahlZyxck8jpZtQ7UvvoTydkLEYvhJW01VXABhombjZM=
redirect_to_url:
user[login]:123
user[password]:13
user[remember_me]:0
commit:登 录
"""
data = {
	"utf8":"✓",
	"authenticity_token":authenticity_token,
	"user[login]":"493083385@qq.com",
	"user[password]":"ZWC8950111",
	"user[remember_me]":"0",
	"commit":"登 录"
}
"""
User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
"""
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"}
# 模拟登陆
login = s.post(url_post, data=data, headers=headers)
html_dest = s.get(url_get, cookies=login.cookies, headers=headers)
print(html_dest.text)